/*
gtime 是一个结构体 time保存的为秒数(windows是从1970-1-1)开始的秒数, sec是剩下的小数秒数

GPS时间比UTC时间有个调整, 如果时间大于{2012,7,1,0,0,0},  需要将UTC时间 + 16 秒

rtklib中声明的结构

	{2012,7,1,0,0,0,-16},
	{2009,1,1,0,0,0,-15},
	{2006,1,1,0,0,0,-14},
	{1999,1,1,0,0,0,-13},
	{1997,7,1,0,0,0,-12},
	{1996,1,1,0,0,0,-11},
	{1994,7,1,0,0,0,-10},
	{1993,7,1,0,0,0, -9},
	{1992,7,1,0,0,0, -8},
	{1991,1,1,0,0,0, -7},
	{1990,1,1,0,0,0, -6},
	{1988,1,1,0,0,0, -5},
	{1985,7,1,0,0,0, -4},
	{1983,7,1,0,0,0, -3},
	{1982,7,1,0,0,0, -2},
	{1981,7,1,0,0,0, -1}
*/
package gnss

import "time"

const (
	SECONDS_PER_DAY  = 60 * 60 * 24
	SECONDS_PER_HOUR = 60 * 60
	SECONDS_PER_WEEK = SECONDS_PER_DAY * 7

	MILL_SECONDS_PER_WEEK = SECONDS_PER_WEEK * 1000
	MILL_SECONDS_PER_DAY  = SECONDS_PER_DAY * 1000
)

type GTime struct {
	time int64   /* time (s) expressed by standard time_t */
	sec  float64 /* fraction of second under 1 s 小数秒*/
}

func CurrentGTime() GTime {
	now := time.Now().UTC()

	tsec := int64(now.Unix() / 1000)
	fsec := float64(now.Unix()-tsec*1000) / 1000
	rval := GTime{
		time: tsec, // 秒钟
		sec:  fsec, // 小数秒
	}

	return rval
}
